<div class="layui-side layui-bg-black">
	<div class="layui-side-scroll">
		<#include "/apps/business/customer/include/left.html">
	</div>
</div>
<div class="layui-body">
	<div class="layui-side-scroll">
		<div class="row">
			<div class="col-lg-12">
				<h1 class="site-h1 ukefu-tab" style="border-top:1px solid #e6e6e6;height:26px;">
					<span class="ukefu-bt">
						<i class="layui-icon ukewo-btn" style="font-size:20px;"></i>
						<div class="ukefu-bt-text">
							<div class="ukefu-bt-text-title">
								全部客户
							</div>
						</div>
					</span>
					<div class="ukefu-tab-title">
						<#include "/apps/business/customer/top.html">
					</div>
					<div class="ukefu-bt-text-content" style="position: absolute;right: 5px;top: 0px;padding-right:10px;">
						<form class="layui-form" name="search" action="/apps/customer/${subtype!''}.html" method="get" style="float: left;">
							<#if ekind??><input type="hidden" name="ekind" value="${ekind!''}"></#if>
							<div class="layui-form-item">
								<div class="layui-inline">
									<div class="layui-input-inline">
										<input type="text" name="q" value="${q!''}" style="height: 30px;line-height: 30px;margin-top: 4px;border: 1px solid #32c24d;"
											placeholder="请输入查询条件" autocomplete="off" class="layui-input">
										<i class="layui-icon" onclick="search.submit()" style="position: absolute;cursor: pointer;right: 3px;top: 4px;font-size: 20px;color:#32c24d;">&#xe615;</i>
									</div>
								</div>
							</div>
						</form>
						<#if user?? && (user.roleAuthMap["A03_A01_A02_B06"]?? || user.usertype == "0") >
						<div class="layui-btn-group ukefu-btn-group">
						  	<a href="/apps/customer/add.html<#if ekind??>?ekind=${ekind}</#if>" title="新建客户" data-toggle="ajax" data-width="950" data-height="600" class="layui-btn layui-btn-small" >
							  	<i class="layui-icon">&#xe608;</i>
							  	新建客户
						  	</a>
						</div>
						</#if>
						<#if user?? && (user.roleAuthMap["A03_A01_A02_B09"]?? || user.usertype == "0") >
						<div class="layui-btn-group ukefu-btn-group">
							<button class="layui-btn layui-btn-small" href="/apps/customer/imp.html<#if ekind??>?ekind=${ekind}</#if>" title="导入客户" data-toggle="ajax" data-width="950" data-height="600">
								<i class="kfont">&#xe641;</i> 导入 
							</button>
						</div>
						</#if>
						
						<#if user?? && (user.roleAuthMap["A03_A01_A02_B010"]?? || user.usertype == "0") >
						<div class="layui-btn-group ukefu-btn-group">
							<button class="layui-btn layui-btn-small dropdown-menu">
								<i class="kfont">&#xe672;</i> 导出 
								<i class="layui-icon">&#xe625;</i>
							</button>
							<ul class="ukefu-dropdown-menu layui-anim layui-anim-upbit">
								<li>
									<a href="javascript:void(0)" id="batexp" title="导出客户" target="_blank">
										<i class="kfont">&#xe672;</i>
										导出选中结果
									</a>
								</li>
								<li>
									<a href="/apps/customer/expsearch.html?1=1<#if q??>&q=${q!''}</#if><#if ekind??>&ekind=${ekind}</#if>&subtype=${subtype}" title="导出客户" target="_blank">
										<i class="kfont">&#xe672;</i>
										导出当前搜索结果
									</a>
								</li>
								<li>
									<a href="/apps/customer/expall.html<#if ekind??>?ekind=${ekind}</#if>" title="导出客户" target="_blank">
										<i class="kfont">&#xe672;</i>
										导出全部数据
									</a>
								</li>
							</ul>
						</div>
						</#if>
					</div>
				</h1>
				<table class="layui-table" lay-skin="line">
					<thead>
						<tr class="design-sortable-tr">
							<th>
								<input type="checkbox" id="all" onclick="$('.ids').prop('checked' , $(this).prop('checked'));"/>
							</th>
							<th>客户名称</th>
							<th>类型</th>
							<th>所在城市</th>
							<th>客户状态</th>
							<th>行业</th>
							<th>成熟度</th>
							<th>获得时间</th>
							<th>所有者</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<#if entCustomerList?? && entCustomerList.content?? && entCustomerList.content?size gt 0>
						<#list entCustomerList.content as entCustomer>
						<tr class="tdHasContorllor design-dropable-td">
							<td style="width:1%;">
								<input type="checkbox" class="ids" name="ids" value="${entCustomer.id!''}"/>
							</td>
							<td class=" first_td_head">
								${entCustomer.name!''}
							</td>
							<td>
								${uKeFuDic[entCustomer.ekind!''].name!''}
							</td>
							<td>
								${uKeFuDic[entCustomer.city!''].name!''}
							</td>
							<td>${uKeFuDic[entCustomer.validstatus!''].name!''}</td>
							<td>
								${uKeFuDic[entCustomer.industry!''].name!''}
							</td>
							<td>
								${uKeFuDic[entCustomer.maturity!''].name!''}
							</td>
							<td>
								<#if entCustomer.touchtime??>
									${entCustomer.touchtime?string('yyyy-MM-dd')}
								</#if>
							</td>
							<td>
								<#if entCustomer.user??>${entCustomer.user.username!''}</#if>
							</td>
							<td style="white-space:nowrap;width:1%;" nowrap="nowrap">
								<#if user?? && (user.roleAuthMap["A03_A01_A02_B07"]?? || user.usertype == "0") >
						  		<a href="/apps/customer/edit.html?id=${entCustomer.id!''}" data-toggle="ajax" data-width="950" data-height="600" data-title="编辑用户信息">
						  			<i class="layui-icon">&#xe642;</i>
						  			编辑
						  		</a>
						  		</#if>
						  		<#if user?? && (user.roleAuthMap["A03_A01_A02_B08"]?? || user.usertype == "0") >
						  		<a href="/apps/customer/delete.html?id=${entCustomer.id!''}" style="margin-left:10px;" data-toggle="tip" data-title="请确认是否删除记录？">
						  			<i class="layui-icon" style="color:red;">&#x1006;</i>
						  			删除
						  		</a>
						  		</#if>
						  	</td>
						</tr>
						</#list>
						<#else>
							<tr>
								<td colspan="20" style="height:400px;">
									<div class="ukefu-empty">
										<i class="layui-icon">&#xe63a;</i>
										<div style="">还没有客户信息</div>
									</div>
								</td>
							</tr>
						</#if>
					</tbody>
				</table>

			</div>
		</div>
		<div class="row" style="padding:5px;">
			<div class="col-lg-12" id="page" style="text-align:center;"></div>
		</div>
	</div>
</div>
<script>
	$(document).ready(function(){
		$('#batexp').click(function(){
			var ids = "";
			var num = 0 ;
			$('.ids').each(function(){
				if($(this).prop("checked")){
					if(ids!=""){
						ids += "&" ;
					}
					ids += "ids=" + $(this).val();
					num++;
				}
			});
			if(num>0){
				$('#batexp').attr('href' , '/apps/customer/expids.html?'+ids)	;
			}else{
				top.layer.alert("请先选择需要导出的客户信息");
				$('#batexp').attr("href" , "javascript:void(0)");
			}
			
			
		});
		
	});	
	layui.use('form', function(){
		var form = layui.form();
	});
	layui.use(['laypage', 'layer'], function(){
		  var laypage = layui.laypage
		  ,layer = layui.layer;
		  
		  laypage({
				cont: 'page'
				,pages: <#if entCustomerList??>${entCustomerList.totalPages}<#else>0</#if> //总页数
				,curr:<#if entCustomerList??>${entCustomerList.number+1}<#else>0</#if>
				,groups: 5 //连续显示分页数
				,jump:function(data , first){
					if(!first){
						location.href = "/apps/customer/${subtype!'index'}.html?p="+data.curr ;
					}
				}
		   });
		});
</script>
